package com.intct.flink;

import org.apache.flink.api.common.RuntimeExecutionMode;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.RestOptions;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author gufg
 * @since 2025-06-24 16:50
 */
public class FromCollectionGetData {
    public static void main(String[] args) throws Exception {
        // 创建环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        // 程序内部设置批量或流式作业
//        env.setRuntimeMode(RuntimeExecutionMode.STREAMING);

        // 提交作业命令设置批量或流式作业
        // flink run -Dexecution.runtime-mode=STREAMING/BATCH

        // 获取数据源
        List<String> asList = Arrays.asList("hello flink", "hello hive", "flink or spark");

//        DataStreamSource<String> dataStreamSource = env.fromCollection(asList);

        DataStreamSource<Integer> dataStreamSource = env.fromElements(2, 3, 5, 6);

        // 转换操作

        // 输出
        dataStreamSource.print();

        // 执行作业
        env.execute("from_collection_read_data");
    }
}
